const BaseIpcHandler = require('../BaseIpcHandler');

class EvalStartHandler extends BaseIpcHandler {
    async handle(event, params) {
        // 解析参数
        // console.log('>> EvalStartHandler params = ', params);
        const { record_id, model_path } = params;

        // 业务逻辑
        let result = null;
        try {
            result = await this.app.model.startEval(record_id, model_path);
        } catch (err) {
            console.error(`Error start evaluate local model: `, err);
            result = { code: -1, msg: err.message };
        }

        // 返回结果
        if (event.from === 'localserver') {
            event.resp.send(result);
        } else {
            return result;
        }
    }
}

module.exports = EvalStartHandler;
